<style lang="stylus" type="text/stylus">
@import 'publish.styl';
</style>

<template>
  <div id="PublishNotice">
    <header>
      <ul class="noticeNav">
        <li>
          <router-link to="/platformManagement/notification">通知</router-link>
        </li>
        <li>/</li>
        <li>发布通知</li>
      </ul>
      <!-- <ul class="loginBtn">
        <li>运维管理员  </li>
        <li><i class="logout iconfont icon-tuichu"></i></li>
      </ul> -->
    </header>
    <div class="publishPage">
      <VuePerfectScrollbar class="contentAside">
        <aside>
          <div class="readNotice" @click="readNotice">+ 阅读通知</div>
          <div class="meetingNotice" @click="meetNotice">+ 会议通知</div>
          <div class="draft">
            <span>草稿</span>
            <div v-show="isShow" class="temp checkedActive">
              <p>{{this.title}}</p>
              <span><Icon type="information-circled"></Icon>&nbsp;&nbsp;<b v-if="type==1">会议通知</b><b
                v-if="type==0">阅读通知</b></span>
            </div>
            <ul>
              <li v-for="item in NoticeDraftList" :key="item.id" @click="chooseTargetOne(item.id)"
                  :class='{"checkedActive":classId==item.id}'>
                <p>{{item.title}}</p>
                <span><Icon type="information-circled"></Icon>&nbsp;&nbsp;<span v-show="item.type==0">阅读通知</span><span
                  v-show="item.type==1">会议通知</span></span>
              </li>
            </ul>
          </div>
          <div class="recycle">
            <span>回收站</span>
            <ul>
              <li v-for="item in NoticeRevokeList" :key="item.id" @click="chooseTargetRecycleInfo(item.id)"
                  :class='{"checkedActive":classId==item.id}'>
                <p>{{item.title}}</p>
                <span><Icon type="information-circled"></Icon>&nbsp;&nbsp;<span v-show="item.type==0">阅读通知</span><span
                  v-show="item.type==1">会议通知</span></span>
              </li>
            </ul>
          </div>
        </aside>
      </VuePerfectScrollbar>
      <article>
        <VuePerfectScrollbar class="contentInfo">
          <ul v-if="isHide">
            <li class="titleList">
              <p>|&nbsp;&nbsp;通知标题</p>
              <input class="titleContent" type="text" ref="publishTitleInfo" placeholder="请输入标题"
                     :value="targetNoticeInfo.title">
            </li>
            <li class="contentList">
              <p>|&nbsp;&nbsp;通知内容</p>
              <div class="notifType" v-if="(!targetNoticeInfo.content&&!editorContent)&& inputActive.textareaActive==0">
                <div class="notifType-sel" @click="inputActive.editorActive=!0">
                  <p class="notifType-title"><em>Markdown</em></p>
                  <p class="notifType-info">采用图文并茂的方式撰写通知内容。例
                    如,向企业完整介绍一场刚刚进行过的
                    活动,使人身临其境。</p>
                </div>
                <div class="notifType-sel" @click="inputActive.textareaActive=!0">
                  <p class="notifType-title"><em>纯文本</em></p>
                  <p class="notifType-info">采用严肃的纯文本来撰写通知内容。例
                    如,通知企业参加会议,交代时间、地
                    点、与会要求。</p>
                </div>

              </div>
              <div class="notificationContent" v-show="editorContent||inputActive.textareaActive==2">
                <p>内容类型: <span>Markdown</span></p>
                <div>
                  <Code class="markdownCon" @click="inputActive.editorActive=!0" v-html="editorContent"></Code>
                  <div class="mark"><span class="iconfont icon-xiangyou"></span></div>
                </div>
                <Button type="text" @click="clearCon">清除</Button>
              </div>
              <div class="notificationContent" v-show="targetNoticeInfo.content || inputActive.textareaActive==1">
                <p>内容类型: <span>纯文本</span></p>
                <div>
                  <textarea ref="publishContentInfo" cols="70" rows="10"
                            :value="targetNoticeInfo.content"></textarea>
                </div>
                <Button type="text" @click="clearCon">清除</Button>
              </div>
            </li>
            <li class="sessionList">
              <p>|&nbsp;&nbsp;通知对象</p>
              <div v-show="isDraft" class="groupInfo">
                <!-- <p class="companyName">企业名:</p> -->
                <ul class="subheadList" v-if="allComanysList.countOrg <=99">
                  <li class="subheadListInfo" v-for="item in chooseTargetCompany" :key="item.id">{{item.name}}</li>
                </ul>
                <span class="allGroupList" v-if="allComanysList.countOrg >=99">已选择全部企业</span>
              </div>
              <div class="subheadListBtn" v-if="isShowDraftEditBtn">
                <a class="subheadListBtn01" href="javascript:void(0)" @click="draftEdit">清除</a><a
                class="subheadListBtn02" href="javascript:void(0)" @click="draftEdit"
                v-if="allComanysList.countOrg <=99">继续添加企业</a>
              </div>
              <div v-if="isDraftEdit" class="groupInfo">
                <div class="groupList" v-show="isNotHideGroupList">
                  <Button type="primary" filterable @click="getNoticePortion">选择通知部分企业</Button>
                  <Modal
                    v-model="modal1"
                    title="选择通知部分企业"
                    width="800px"
                    @on-ok="ok"
                    @on-cancel="cancel">
                    <Select v-model="group" filterable multiple>
                      <Option v-for="item in groupList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                    </Select>
                  </Modal>
                  <Button type="info" @click="getNoticeAllCompanys">通知全部企业</Button>
                </div>
                <div class="groupListInfo" v-show="isHideGroupList">
                  <ul class="subheadList">
                    <li class="subheadListInfo" v-for="(item,index) in checkedGroupListInfo" :key="index">
                      {{item.orgName}}
                    </li>
                  </ul>
                </div>
                <span class="allGroupListInfo" v-show="isShowAllGroupList">已选择全部企业</span>
                <a class="groupListInfoBtn01" href="javascript:void(0)" @click="draftEdit">清除</a>
              </div>

            </li>
            <!-- 阅读通知-企业回复最迟期限 -->
            <li v-show="targetNoticeInfo.type == 0" @click="editDraftDeadline" class="deadlineList">
              <p>|&nbsp;&nbsp;要求企业回应通知的最迟期限</p>
              <div class="respondDeadline">
                <ul class="deadlineTimeList" v-if="isDraftDeadlineTime">
                  <li class="time01">2017</li>
                  <li>年</li>
                  <li class="time02">9</li>
                  <li>月</li>
                  <li class="time03">13<span>周五</span></li>
                  <li>日</li>
                  <!-- <li class="time04">=</li>
                  <li class="time05">91</li>
                  <li>自然日后</li> -->
                </ul>
                <ul class="deadlineTimeListEdit" v-if="isDraftDeadlineEdit">
                  <li>
                    <Row v-if="targetNoticeInfo.type == 0">
                      <Col span="12">
                      <DatePicker :value="targetNoticeInfo.endDateText" format="yyyy-MM-dd" type="datetime"
                                  placeholder="请选择时间" style="width: 200px" @on-change="getDateValue"></DatePicker>
                      </Col>
                    </Row>
                    <Row v-if="targetNoticeInfo.type == 1">
                      <Col span="12">

                      <DatePicker :value="targetNoticeInfo.endDateText" format="yyyy-MM-dd HH:mm" type="datetime"
                                  placeholder="请选择时间" style="width: 200px" @on-change="getDateValue"></DatePicker>
                      </Col>
                    </Row>
                  </li>
                </ul>
              </div>
            </li>
            <!-- 会议通知-企业回复最迟期限 -->
            <li v-show="targetNoticeInfo.type == 1" class="deadlineList">
              <p>|&nbsp;&nbsp;会议具体时间</p>
              <div class="respondDeadline">
                <ul class="deadlineTimeList" v-if="isDraftDeadlineTime">
                  <li class="time01">2017</li>
                  <li>年</li>
                  <li class="time02">9</li>
                  <li>月</li>
                  <li class="time03">13<span>周五</span></li>
                  <li>日</li>
                  <li class="time02">9</li>
                  <li>时</li>
                  <li class="time03">13</li>
                  <li>分</li>
                </ul>
                <ul class="deadlineTimeListEdit" v-if="isDraftDeadlineEdit">
                  <li>
                    <Row>
                      <Col span="12">
                      <DatePicker :value="targetNoticeInfo.meetDateText" format="yyyy-MM-dd HH:mm" type="datetime"
                                  placeholder="请选择时间" style="width: 200px" @on-change="getDateValue"></DatePicker>
                      </Col>
                    </Row>
                  </li>
                </ul>
              </div>
            </li>
            <li v-show="targetNoticeInfo.type == 1" class="meetStartTimeStyle">
              <p>|&nbsp;&nbsp;要求企业回应通知的最迟期限</p>
              <div class="respondDeadline">
                <ul class="deadlineTimeList">
                  <li>会议开始前</li>
                  <li class="time04">1</li>
                  <li>自然日</li>
                </ul>
              </div>
            </li>
          </ul>
          <ul v-if="isShow">
            <li class="titleList">
              <p>|&nbsp;&nbsp;通知标题</p>
              <input class="titleContent" type="text" ref="publishTitleInfo" placeholder="请输入标题">
              <!-- </div> -->
            </li>
            <!-- <li class="contentList">
              <p>|&nbsp;&nbsp;通知内容</p>
              <div class="notificationContent">
                <div>
                  <textarea ref="publishContentInfo" id="" cols="70" rows="10" placeholder="请输入内容"></textarea>
                </div>
              </div>
            </li> -->

            <li class="contentList">
              <p>|&nbsp;&nbsp;通知内容</p>
              <div class="notifType" v-if="inputActive.textareaActive==0">
                <div class="notifType-sel" @click="inputActive.editorActive=!0">
                  <p class="notifType-title"><em>Markdown</em></p>
                  <p class="notifType-info">采用图文并茂的方式撰写通知内容。例
                    如,向企业完整介绍一场刚刚进行过的
                    活动,使人身临其境。</p>
                </div>
                <div class="notifType-sel" @click="inputActive.textareaActive=!0">
                  <p class="notifType-title"><em>纯文本</em></p>
                  <p class="notifType-info">采用严肃的纯文本来撰写通知内容。例
                    如,通知企业参加会议,交代时间、地
                    点、与会要求。</p>
                </div>

              </div>
              <div class="notificationContent" v-if="inputActive.textareaActive==2">
                <p>内容类型: <span>Markdown</span></p>
                <div>
                  <Code class="markdownCon" @click="inputActive.editorActive=!0" v-html="editorContent"></Code>
                  <div class="mark"><span class="iconfont icon-xiangyou"></span></div>
                </div>
                <Button type="text" @click="clearCon">清除</Button>
              </div>
              <div class="notificationContent" v-if="inputActive.textareaActive==1">
                <p>内容类型: <span>纯文本</span></p>
                <div>
                  <textarea ref="publishContentInfo" cols="70" rows="10"></textarea>
                </div>
                <Button type="text" @click="clearCon">清除</Button>
              </div>
            </li>

            <li class="sessionList">
              <p>|&nbsp;&nbsp;通知对象</p>
              <!-- <div v-show="isDraft" class="groupInfo">
                  <div class="groupList" v-show="isNotShowGroupListInfo">
                    <Button type="primary" filterable @click="getNoticePortion">选择通知部分企业</Button>
                      <Modal
                          v-model="modal1"
                          title="选择通知部分企业"
                          width="800px"
                          @on-ok="ok"
                          @on-cancel="cancel">
                          <Select v-model="group" filterable multiple>
                              <Option v-for="item in groupList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                          </Select>
                      </Modal>
                    <Button type="info" @click="getNoticeAllCompanys">通知全部企业</Button>
                    <span class="allGroupListInfo"v-show="isShowAllGroupList">已选择全部企业</span>
                  </div>

                  <a href="javascript:void(0)" @click="emptyGroupList"  v-show="isHideGroupList">清除</a>
              </div> -->
              <div v-show="isDraft" class="groupInfo">
                <div class="groupList" v-show="isNotShowGroupListInfo">
                  <Button type="primary" filterable @click="getNoticePortion">选择通知部分企业</Button>
                  <Modal
                    v-model="modal1"
                    title="选择通知部分企业"
                    width="800px"
                    @on-ok="ok"
                    @on-cancel="cancel">
                    <Select v-model="group" filterable multiple>
                      <Option v-for="item in groupList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                    </Select>
                  </Modal>
                  <Button type="info" @click="getNoticeAllCompanys">通知全部企业</Button>
                  <a href="javascript:void(0)" @click="emptyGroupList" v-show="isHideGroupList">清除</a>
                </div>
                <div class="groupListInfo" v-show="isHideGroupList">
                  <ul class="subheadList">
                    <li class="subheadListInfo" v-for="(item,index) in checkedGroupListInfo" :key="index">
                      {{item.orgName}}
                    </li>
                  </ul>
                </div>
                <span class="allGroupListInfo" v-show="isShowAllGroupList">已选择全部企业</span>
                <a href="javascript:void(0)" @click="emptyGroupList" v-show="isHideGroupListDelet">清除</a>
              </div>
            </li>
            <li class="deadlineList">
              <p>|&nbsp;&nbsp;要求企业回应通知的最迟期限</p>
              <div class="respondDeadline">
                <!-- <input type="text" v-model="yearTime" placeholder="yearTime" value="">年
                <input type="text" v-model="monthTime" placeholder="monthTime" value="" @input="changeTime">月
                <input type="text" v-model="dayTime" placeholder="dayTime" value="">日&nbsp;=
                <input type="text" v-model="deadTime" placeholder="deadTime" value="">自然日后 -->

                <Row v-if="this.type == 0">
                  <Col span="12">
                  <DatePicker type="datetime" format="yyyy-MM-dd" placeholder="请选择时间" style="width: 200px"
                              @on-change="getDateValue"></DatePicker>
                  </Col>
                </Row>

                <Row v-if="this.type == 1">
                  <Col span="12">
                  <DatePicker type="datetime" format="yyyy-MM-dd HH:mm" placeholder="请选择时间" style="width: 200px"
                              @on-change="getDateValue"></DatePicker>
                  </Col>
                </Row>
              </div>
            </li>
          </ul>
        </VuePerfectScrollbar>
        <div class="tabBarBottom">
          <ul v-if="editNotice">
            <li class="tabBar-01" @click="goBackPub">删除</li>
            <li class="tabBar-03" @click="savNotice">保存草稿</li>
            <li class="tabBar-04" @click="pubNotice">发布通知</li>
          </ul>
          <ul v-if="recycleBin">
            <li class="tabBar-05" @click="thoroughlyDel">彻底删除</li>
            <li class="tabBar-06" @click="restore">还原</li>
          </ul>
        </div>
      </article>
    </div>

    <div class="editor-layer" v-if="inputActive.editorActive">
      <div class="editor">
        <quillEditor id="quillEditor" v-model="editorContent"
                     :options="editorOption">
          <div id="toolbar" slot="toolbar">
            <!-- Add font size dropdown -->
            <select class="ql-header">
              <option selected="selected" value="1">H1</option>
              <option value="2">H2</option>
              <option value="3">H3</option>
              <option value="4">H4</option>
              <option value="5">H5</option>
              <option value="6">H6</option>
            </select>

            <!-- Add a bold button -->
            <button class="ql-bold"></button>
            <button class="ql-italic"></button>
            <button class="ql-underline"></button>
            <button class="ql-strike"></button>

            <button class="ql-list" value="ordered"></button>
            <button class="ql-list" value="bullet"></button>

            <button class="ql-indent" value="-1"></button>
            <button class="ql-indent" value="+1"></button>

            <select class="ql-color">
              <option selected="selected"></option>
              <option
                value="#e60000"></option>
              <option value="#ff9900"></option>
              <option value="#ffff00"></option>
              <option
                value="#008a00"></option>
              <option value="#0066cc"></option>
              <option value="#9933ff"></option>
              <option
                value="#ffffff"></option>
              <option value="#facccc"></option>
              <option value="#ffebcc"></option>
              <option
                value="#ffffcc"></option>
              <option value="#cce8cc"></option>
              <option value="#cce0f5"></option>
              <option
                value="#ebd6ff"></option>
              <option value="#bbbbbb"></option>
              <option value="#f06666"></option>
              <option
                value="#ffc266"></option>
              <option value="#ffff66"></option>
              <option value="#66b966"></option>
              <option
                value="#66a3e0"></option>
              <option value="#c285ff"></option>
              <option value="#888888"></option>
              <option
                value="#a10000"></option>
              <option value="#b26b00"></option>
              <option value="#b2b200"></option>
              <option
                value="#006100"></option>
              <option value="#0047b2"></option>
              <option value="#6b24b2"></option>
              <option
                value="#444444"></option>
              <option value="#5c0000"></option>
              <option value="#663d00"></option>
              <option
                value="#666600"></option>
              <option value="#003700"></option>
              <option value="#002966"></option>
              <option
                value="#3d1466"></option>
            </select>

            <select class="ql-background">
              <option value="#000000"></option>
              <option
                value="#e60000"></option>
              <option value="#ff9900"></option>
              <option value="#ffff00"></option>
              <option
                value="#008a00"></option>
              <option value="#0066cc"></option>
              <option value="#9933ff"></option>
              <option
                selected="selected"></option>
              <option value="#facccc"></option>
              <option value="#ffebcc"></option>
              <option
                value="#ffffcc"></option>
              <option value="#cce8cc"></option>
              <option value="#cce0f5"></option>
              <option
                value="#ebd6ff"></option>
              <option value="#bbbbbb"></option>
              <option value="#f06666"></option>
              <option
                value="#ffc266"></option>
              <option value="#ffff66"></option>
              <option value="#66b966"></option>
              <option
                value="#66a3e0"></option>
              <option value="#c285ff"></option>
              <option value="#888888"></option>
              <option
                value="#a10000"></option>
              <option value="#b26b00"></option>
              <option value="#b2b200"></option>
              <option
                value="#006100"></option>
              <option value="#0047b2"></option>
              <option value="#6b24b2"></option>
              <option
                value="#444444"></option>
              <option value="#5c0000"></option>
              <option value="#663d00"></option>
              <option
                value="#666600"></option>
              <option value="#003700"></option>
              <option value="#002966"></option>
              <option
                value="#3d1466"></option>
            </select>

            <select class="ql-align">
              <option selected="selected"></option>
              <option value="center"></option>
              <option value="right"></option>
              <option value="justify"></option>
            </select>

            <!-- Add subscript and superscript buttons -->
            <button class="ql-script" value="sub"></button>
            <button class="ql-script" value="super"></button>

            <button class="ql-image">Image</button>
            <!-- You can also add your own -->
            <button id="custom-button" style="width: 60px;" @click="filesActive = !0">附件</button>

          </div>
        </quillEditor>
        <div class="btn-editor">
          <span @click="closeEditor" class="close-editor icon-close iconfont"></span>
        </div>
      </div>

    </div>
    <Modal title="上传附件" v-model="filesActive">
      <ul>
        <li></li>
      </ul>
      <div slot="footer">
        <Upload :show-upload-list="false"
                :with-credentials="!0"
                :action="uploadUrl"
                :data="{moduleName:'notice'}"
                :on-success="uploadFiles">
          <Button type="primary" icon="ios-cloud-upload-outline" long>上传附件</Button>
        </Upload>
      </div>
    </Modal>

  </div>
</template>

<script>
import common from "../../../common/common.js";

import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";

import { quillEditor } from "vue-quill-editor";

export default {
  name: "Publish",
  data() {
    return {
      isShow: false,
      isHide: true,

      isDraft: true,
      isDraftEdit: false,

      isDraftDeadlineTime: false,
      isDraftDeadlineEdit: true,

      readStartTime: true,
      meetingStartTime: false,

      isMeetingTime: true,
      isShowDraftEditBtn: true,

      isNotShowGroupListInfo: true,
      isShowGroupListInfo: false,

      isNotHideGroupList: true,
      isHideGroupList: false,
      isShowAllGroupList: false,
      isHideGroupListDelet: true,

      title: "",
      content: "",
      groupList: [],
      group: [],
      modal1: false,
      type: null,
      buttenFlag: "0",
      NoticeDraftList: [],
      NoticeRevokeList: [],
      checkedGroupListInfo: [],
      yearTime: "",
      monthTime: "",
      dayTime: "",
      deadTime: 0,
      beginDate: "",
      classId: null,
      targetNoticeInfo: {},
      chooseTargetCompany: {},
      allComanysList: {},
      deletId: "",
      targetId: "",
      restoreId: "",
      targetRecycleId: "",
      targetRecycleId: "",
      recycleBin: false,
      editNotice: true,
      DateValue: "",

      inputActive: {
        textareaActive: false,
        editorActive: false
      },
      editorContent: "",
      editorOption: {
        modules: {
          toolbar: "#toolbar",
          history: {
            delay: 1000,
            maxStack: 50,
            userOnly: false
          }
        }
      },
      uploadUrl: this._URL_v2 + "/filecommon/uploadFile",
      filesActive: false
    };
  },
  created() {
    this.getCompanysList();
    this.getNoticeDraft();
    this.getNoticeRevoke();
    // this.defaultTargetOne();
  },
  mounted() {
    this.getDeadlineTime();
  },
  methods: {
    //获取用户选择的日期
    getDateValue(value) {
      this.DateValue = value;
    },
    //获取所有企业列表
    getCompanysList() {
      const url = `${common.apihost}notice/findOtherGroupAll`;
      this.$http.get(url).then(response => {
        this.groupList = response.body.result;
      });
    },
    //获取草稿列表
    getNoticeDraft() {
      const url = `${common.apihost}notice/findNoticeAllForBack`;
      this.$http.get(url).then(response => {
        this.NoticeDraftList = response.body.result.draft;
        this.classId = this.NoticeDraftList[0].id;
        const classId = this.classId;
        const url = `${common.apihost}notice/findNoticeDetailsForGov`;
        this.$http
          .post(url, { id: classId }, { emulateJSON: true })
          .then(response => {
            this.targetNoticeInfo = response.body.result;
            const url = `${common.apihost}notice/findOtherGroupByNoticeId`;
            this.$http
              .post(url, { id: classId }, { emulateJSON: true })
              .then(response => {
                this.allComanysList = response.body.result[0];
                this.chooseTargetCompany = response.body.result[0].orgList;
              });
          });
      });
    },
    //获取回收站列表
    getNoticeRevoke() {
      this.isDraftEdit = false;
      const url = `${common.apihost}notice/findNoticeAllForBack`;
      this.$http.get(url).then(response => {
        this.NoticeRevokeList = response.body.result.revoke;
      });
    },
    //发布通知
    pubNotice(nodesc) {
      this.classId = null;
      if (this.$refs.publishTitleInfo.value == "") {
        this.$Notice.error({
          title: "请输入标题！",
          desc: nodesc ? "" : "请输入标题！"
        });
        return;
      }
      if (this.DateValue == "") {
        this.$Notice.error({
          title: "请选择日期！",
          desc: nodesc ? "" : "请选择日期！"
        });
        return;
      }
      if (this.group == "") {
        this.$Notice.error({
          title: "请选择企业！",
          desc: nodesc ? "" : "请选择企业！"
        });
        return;
      }

      let title = this.$refs.publishTitleInfo.value;
      let editorContent = this.editorContent;
      let content = this.$refs.publishContentInfo
        ? this.$refs.publishContentInfo.value
        : editorContent;
      let textType = editorContent ? "markdown" : "纯文本";
      let group = group != "" ? this.group.join(",") : "";
      let beginDate = this.beginDate;
      let id = id == "" ? "" : this.targetId;
      // let lastRecoveryTime = this.getDateValue;
      let endDay = endDay != "" ? this.DateValue : "";
      let type = this.type == null ? this.targetNoticeInfo.type : this.type;
      this.buttenFlag = 1;
      const url = `${common.apihost}notice/saveOfSubDraft`;
      this.$http
        .post(
          url,
          {
            title: title,
            content: content,
            type: type,
            textType: textType,
            companys: group,
            endDay: endDay,
            buttenFlag: this.buttenFlag,
            id: id
          },
          { emulateJSON: true }
        )
        .then(response => {
          this.isShow = false;
          this.isHide = true;
          group = "";
          this.checkedGroupListInfo = "";
          this.$Message.success("通知发布成功！");
          this.$router.push({ path: "/platformManagement/notification" });
          // window.location.reload();
        })
        .catch(response => {
        });
    },
    //保存草稿
    savNotice() {
      this.classId = null;
      let title = this.$refs.publishTitleInfo.value;
      let editorContent = this.editorContent;
      let content = this.$refs.publishContentInfo
        ? this.$refs.publishContentInfo.value
        : editorContent;
      let textType = editorContent ? "markdown" : "纯文本";
      let group = this.group.join(",");
      let beginDate = this.beginDate;
      let endDay = this.DateValue;
      let type = this.type == null ? this.targetNoticeInfo.type : this.type;
      this.buttenFlag = 0;
      const url = `${common.apihost}notice/saveOfSubDraft`;

      this.$http
        .post(
          url,
          {
            title: title,
            content: content,
            type: type,
            textType: textType,
            companys: group,
            // beginDate: beginDate,
            endDay: endDay,
            // lastRecoveryTime: "28",
            buttenFlag: this.buttenFlag
          },
          { emulateJSON: true }
        )
        .then(response => {
          this.$Message.success("草稿保存成功！");
          this.isShow = false;
          this.isHide = true;
          group = "";
          this.checkedGroupListInfo = "";
          // window.location.reload();
        });
    },
    //类型变更为 阅读通知 并且实现点击高亮
    readNotice() {
      this.isShow = true;
      this.isHide = false;
      this.isDraft = true;
      this.classId = null;
      this.editNotice = true;
      this.recycleBin = false;
      this.type = 0;
    },
    //类型变更为 会议通知 并且实现点击高亮
    meetNotice() {
      this.isShow = true;
      this.isHide = false;
      this.isDraft = true;
      this.classId = null;
      this.editNotice = true;
      this.recycleBin = false;
      this.type = 1;
    },
    //点击通知对象模块切换到选择企业模式
    draftEdit() {
      this.isNotHideGroupList = true;
      this.isHideGroupList = false;
      this.isShowAllGroupList = false;
      this.isShowDraftEditBtn = false;
      this.isDraft = false;
      this.isDraftEdit = true;
    },
    //点击通知时间模块切换到时间选择模式
    editDraftDeadline() {
      this.isDraftDeadlineTime = false;
      this.isDraftDeadlineEdit = true;
    },
    //选中当前项并且获取对应的数据
    chooseTargetOne(id) {
      this.recycleBin = false;
      this.editNotice = true;

      this.isShow = false;
      this.isHide = true;

      this.isDraft = true;
      this.isDraftEdit = false;

      this.isDraftDeadlineTime = false;
      this.isDraftDeadlineEdit = true;

      this.isShowDraftEditBtn = true;

      this.targetId = id;
      const url = `${common.apihost}notice/findNoticeDetailsForGov`;
      this.$http.post(url, { id: id }, { emulateJSON: true }).then(response => {
        this.targetNoticeInfo = response.body.result;
        this.classId = this.targetNoticeInfo.id;
        const url = `${common.apihost}notice/findOtherGroupByNoticeId`;
        this.$http
          .post(url, { id: id }, { emulateJSON: true })
          .then(response => {
            this.chooseTargetCompany = response.body.result[0].orgList;
            this.allComanysList = response.body.result[0];
            this.checkedGroupListInfo = "";
          });
      });
    },
    //选中回收站列表并且获取对应的数据
    chooseTargetRecycleInfo(id) {
      this.recycleBin = true;
      this.editNotice = false;
      this.isShow = false;
      this.isHide = true;
      this.targetRecycleId = id;
      const url = `${common.apihost}notice/findNoticeDetailsForGov`;
      this.$http.post(url, { id: id }, { emulateJSON: true }).then(response => {
        this.targetNoticeInfo = response.body.result;
        this.classId = this.targetNoticeInfo.id;
        const url = `${common.apihost}notice/findOtherGroupByNoticeId`;
        this.$http
          .post(url, { id: id }, { emulateJSON: true })
          .then(response => {
            this.chooseTargetCompany = response.body.result[0].orgList;
            this.allComanysList = response.body.result[0];
            this.checkedGroupListInfo = "";
          });
      });
    },
    //  删除草稿
    goBackPub() {
      this.isShow = false;
      this.isHide = true;
      this.deletId = this.targetId;
      const url = `${common.apihost}notice/deleteNotice`;
      this.$http
        .post(url, { id: this.deletId }, { emulateJSON: true })
        .then(response => {
          this.$Message.success("删除成功！");
          window.location.reload();
        });
    },
    //  删除（彻底删除）
    thoroughlyDel() {
      this.thoroughlyDel = this.targetRecycleId;
      const url = `${common.apihost}notice/deleteNotice`;
      this.$http
        .post(url, { id: this.thoroughlyDel }, { emulateJSON: true })
        .then(response => {
          this.$Message.success("彻底删除成功！");
          window.location.reload();
        });
    },
    //  还原（将回收站的通知还原到草稿箱）
    restore() {
      this.restoreId = this.targetRecycleId;
      const url = `${common.apihost}notice/reductionNotice`;
      this.$http
        .post(url, { id: this.restoreId }, { emulateJSON: true })
        .then(response => {
          this.$Message.success("还原成功！");
          window.location.reload();
        });
    },
    //  确定选择企业
    ok() {
      (this.isNotHideGroupList = false),
        (this.isHideGroupList = true),
        (this.isNotShowGroupListInfo = false);
      this.isShowGroupListInfo = true;
      let group = this.group.join(",");
      this.$Message.info("内容选择完成！");
      let companyIds = this.group.join(",");
      const url = `${common.apihost}notice/findOrgNameById`;
      this.$http
        .post(url, { companyIds: companyIds }, { emulateJSON: true })
        .then(response => {
          this.checkedGroupListInfo = response.body.result;
        });
    },
    //  取消选择企业
    cancel() {
      (this.isNotHideGroupList = false),
        (this.isHideGroupList = true),
        (this.isNotShowGroupListInfo = true);
      this.isShowGroupListInfo = false;
      this.$Message.info("已自动保存选择内容！");
    },
    //  获取当前时间
    getDeadlineTime() {
      let DeadlineTime = new Date();
      this.yearTime = DeadlineTime.getFullYear();
      this.monthTime = DeadlineTime.getMonth() + 1;
      this.dayTime = DeadlineTime.getDate();
      this.HoursTime = DeadlineTime.getHours();
      this.MinutesTime = DeadlineTime.getMinutes();
      this.beginDate =
        this.yearTime +
        "-" +
        this.monthTime +
        "-" +
        this.dayTime +
        " " +
        this.HoursTime +
        ":" +
        this.MinutesTime;
    },
    //  将 发布通知中的 参数 group变为 ALL
    getNoticeAllCompanys() {
      this.isShowAllGroupList = true;
      this.isNotHideGroupList = false;
      this.isNotShowGroupListInfo = false;
      this.isHideGroupList = false;
      this.isHideGroupListDelet = true;
      this.group = ["ALL"];
      this.$Message.success("已选中全部企业！");
    },
    //  将 发布通知中的 参数 group 以数组的形式拼接
    getNoticePortion() {
      this.modal1 = true;
      let group = this.group.join(",");
    },
    //  清空已经选中的企业
    emptyGroupList() {
      this.group.length = 0;
      this.isHideGroupList = false;
      this.isHideGroupListDelet = false;
      this.isNotShowGroupListInfo = true;
      this.isShowAllGroupList = false;
    },

    fileShow() {},
    closeEditor() {
      this.inputActive.editorActive = false;
      if (this.editorContent) {
        this.inputActive.textareaActive = 2;
      }
    },
    uploadFile() {},
    clearCon() {
      this.inputActive.textareaActive = 0;
      this.targetNoticeInfo.content = "";
      this.editorContent = "";
    },
    uploadFiles() {}
  },
  components: {
    quillEditor
  }
};
</script>
